<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>登录</title>
	
	<link rel="stylesheet" type="text/css" href="CSS/login.css">
	<script type="text/javascript" src="Js/jquery-2.1.4.min.js"></script>
	<script type="text/javascript">
		$(function()
		{
			
			$("[name='account']").blur(function()
			{
				var account = $.trim($("[name='account']").val());
				if(account==null||account=="")
				{
					$("#email_notice").html("<font color=\"red\">账号不能为空</font>");
				}else if(chekmail(account))
				{
					
					$("#email_notice").html("<font color=\"green\">√</font>");
				}
				else
				{
					$("#email_notice").html("<font color=\"red\">邮箱格式不正确</font>");
				}
			});
			$("[name='password']").blur(function()
			{
				var password = $.trim($("[name='password']").val());
				if(password==null || password=="")
				{
					$("#pwd_notice").html("<font color=\"red\">密码不能为空</font>");
				}
				else
				{
					$("#pwd_notice").html("");
				}
			});
			$("[name='submit']").click(function()
			{
				var account = $.trim($("[name='account']").val());
				var password= $.trim($("[name='password']").val());
				$.post("<%=basePath%>login.action",
					{account:account,password:password},
					function(data){
						
						if(data.result="0")
						{
							
							location.href="index.jsp";
						}
						else
						{
							//alert(data.result);
						}
					},
					"json");
				
				
			});
			
		});
		function chekmail(tmail) 
		{  
			var pattern = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i;  
		 	if(pattern.test(tmail)) 
		 	{  
		  		return true;  
			}  
		 	else 
		 	{  
		  		return false;  
		 	}  
		} 
	</script>
  </head>
  
  <body>
    <!--头部-->
    <div class="topbar-container">
	    <div class="topbar">
	
	        <div class="pure-g">
	            <div class="pure-u-1-6">
	                <a href="/foodfood/AOHomePage..action" class="logo"><img src="./files/logo.png"></a>
	            </div>
	            <div class="pure-u-2-3">&nbsp;</div>
	            <div class="pure-u-1-6 site-nav align-right">没有账号？<a href="register.jsp" class="logo">注册</a></div>
	        </div>
	    </div>
	</div>
    <!--内容-->
    <div class="page-outer">
        <div class="page-container">
            <div class="p40 has-top-border has-bottom-border">
                <div class="page-title align-center pb40"><div class="tittle">经常登录的同志是好同志</div></div>
                <div class="font14">
                    <form action="<%=basePath %>login.action"> 
                        <div class="email">
                            <div class="label">账号</div>
                            <input type="email" name="account" placeholder="someone@example.com">
                            <span id="email_notice"></span><br>
                        </div>
                        <div class="password">
                            <div class="label">密码</div>
                            <input type="password" name="password" id="password">
                            <span id="pwd_notice"></span><br>
                        </div>
                        <div class="zhuce">
                            <input type="button" name="submit"  value="登录"><a href="" class="forget">忘记密码</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
  </body>
</html>

